/**
 * 
 */
package com.transer.utils;

import java.util.UUID;

/**
 * @author Administrator
 * 
 */
public class Utils {
	public static void main(String[] args) {
		// for (Object key : System.getProperties().keySet()) {
		// System.out.println(key + " : " + System.getProperty(getString(key)));
		// }
		System.out.println(getUUID().length());
		System.out.println(getString(null).length());
	}

	/** 路径分隔符 */
	public static final String SEPARATOR_FILE = System.getProperty("file.separator");
	/** 用户操作路径 */
	public static final String USER_DIR = System.getProperty("user.dir");

	/**
	 * 获取随机的UUID
	 * 
	 * @return UUID
	 */
	public static final String getUUID() {
		return UUID.randomUUID().toString();
	}

	/**
	 * 获取参数的String
	 * 
	 * @param src
	 *            源
	 * @return
	 */
	public static String getString(Object src) {
		return src == null ? null : String.valueOf(src);
	}

	/**
	 * 获取参数的Boolean
	 * 
	 * @param src
	 *            源
	 * @return
	 */
	public static boolean getBoolean(Object src) {
		try {
			String decode = getString(src);
			return "on".equalsIgnoreCase(decode) || Boolean.valueOf(decode) || "1".equalsIgnoreCase(decode);
		} catch (Exception e) {
		}
		return false;
	}

	public static int getInteger(Object src) {
		try {
			return Integer.parseInt(getString(src));
		} catch (NumberFormatException e) {
			// e.printStackTrace();
		}
		return 0;
	}

	/**
	 * 是否包含全角
	 * 
	 * @param src
	 *            源
	 * @return
	 */
	public static boolean isFull(Object src) {
		String val = getString(src);
		int length = val.length();
		return length != val.getBytes().length;
	}

	/**
	 * 暂停线程
	 * 
	 * @param delay
	 *            停止时间长度
	 */
	public static void sleep(int delay) {
		try {
			Thread.sleep(delay);
		} catch (InterruptedException e) {
		}
	}
}
